<?php 

require('includes/application_top.php');

if(isset($_POST['check']) && $_POST['check']=="yes") { 
if(isset($_POST['e'])) { $email = tep_db_prepare_input($_POST['e']); } else { $email = ""; }
if(isset($_POST['o'])) { $orderid = tep_db_prepare_input($_POST['o']); } else { $orderid = ""; }
if(isset($_POST['l'])) { $languages_id = tep_db_prepare_input($_POST['l']); } else { $languages_id = "1"; }

  	
  	$query = tep_db_query("select osh.orders_id, osh.date_added, osh.comments, os.orders_status_name
  							FROM ".TABLE_ORDERS_STATUS_HISTORY." osh, ".TABLE_ORDERS_STATUS." os, ".TABLE_ORDERS." o 
  							WHERE osh.orders_status_id = os.orders_status_id 
  							AND o.orders_id=osh.orders_id
  							AND o.customers_email_address = '".$email."'
  							AND os.language_id='".$languages_id."' 
  							AND osh.orders_id ='".$orderid."' 
  							ORDER BY date_added desc
  							LIMIT 1");
  	if (tep_db_num_rows($query) > 0) {
  	while ($status = tep_db_fetch_array($query)) { 
  			if ($status['comments']=="") { $comments = TEXT_ORDER_STATUS_NO_COMMENTS; } else { $comments = $status['comments']; } 
  			
  			$message = '<div class="messageStackSuccess" style="text-align: left;"><b>'.ENTRY_ORDER_NUMBER.'</b> '.$orderid.'<br/>
  					   '.RESULT_ORDER_STATUS.' '.$status['orders_status_name'].'<br/>
  					   '.RESULT_ORDER_STATUS_UPDATED. tep_date_short($status['date_added']).'<br/>
  					   '.$track
  						.RESULT_ORDER_COMMENTS.' '.$comments.'<br/>
  					   '.TEXT_ORDER_STATUS_MORE."</div>";



}   
echo $message;
}  else echo '<div class="messageStackError" style="text-align: left;">'.TEXT_ORDER_STATUS_ERROR.'</div>';

} else {
	tep_redirect(FILENAME_DEFAULT);
}	
?>